#include "Ctrl/PackageController.hpp"

namespace Ctrl
{
	

void PackageController::subscribeToCurrentPackageChanged( const PackageSelectionSlot::slot_type& slot )
{
	onCurrentPackageChanged_.connect( slot);
}

// ---------------------------------------------------------------------------------------------------------------------

void PackageController::setCurrentPackage( Model::Package* pNewCurrentPackage )
{
	if( pNewCurrentPackage != pCurrentPackage_)
	{
		pCurrentPackage_ = pNewCurrentPackage;
		onCurrentPackageChanged_( pCurrentPackage_);
	}
}

// ---------------------------------------------------------------------------------------------------------------------

void PackageController::subscribeToPackageRemoved( const PackageRemovedSlot::slot_type& slot )
{
	onPackageRemoved_.connect( slot);
}

// ---------------------------------------------------------------------------------------------------------------------

void PackageController::subscribeToNewPackageAdded( const NewPackageAddedSlot::slot_type& slot )
{
	onPackageAdded_.connect( slot);
}

// ---------------------------------------------------------------------------------------------------------------------

void PackageController::subscribeToRootRequirementRemoved( const RootRequirementRemovedSlot::slot_type& slot )
{
	onRootRequirementRemoved_.connect( slot);
}

// ---------------------------------------------------------------------------------------------------------------------

void PackageController::subscribeToRootRequirementAdded( const RootRequirementAddedSlot::slot_type& slot )
{
	onRootRequirementAdded_.connect( slot);
}

// ---------------------------------------------------------------------------------------------------------------------

void PackageController::announcePackageRemoved( Model::Package* pParentPackage, Model::Package* pRemovedPackage )
{
	onPackageRemoved_( pParentPackage, pRemovedPackage);
}

// ---------------------------------------------------------------------------------------------------------------------

void PackageController::announceNewPackageAdded( Model::Package* pParentPackage, Model::Package* pNewPackage )
{
	onPackageAdded_( pParentPackage, pNewPackage);
}

// ---------------------------------------------------------------------------------------------------------------------

void PackageController::announceRootRequirementAdded( Model::Package* pPackage, Model::Requirement* pAddedRequirement )
{
	onRootRequirementAdded_( pPackage, pAddedRequirement);
}

// ---------------------------------------------------------------------------------------------------------------------

void PackageController::announceRootRequirementRemoved( Model::Package* pPackage, Model::Requirement* pRemovedRequirement )
{
	onRootRequirementRemoved_( pPackage, pRemovedRequirement);
}


} // namespace Ctrl
